package com.ease.platform.access.service;

import java.util.List;
import java.util.Map;

import com.ease.actionscript.Remoting;
import com.ease.common.vo.Ordering;
import com.ease.common.vo.Pagination;
import com.ease.model.Model;
import com.ease.model.criteria.CriteriaParameter;
import com.ease.platform.access.callback.BatchAccessCallback;
import com.ease.platform.auditlog.annotation.Auditable;

/**
 * 
 * @author nathanleewei
 * 
 */
public interface AbstractParameterizedBeanIbatisAccessService<T extends Model> extends AbstractParameterizedBeanJdbcTemplateAccessService<T> {

	/**
	 * 
	 * @param id
	 * @param userContext
	 * @return
	 */
	@Auditable(false)
	T findById(long id);

	/**
	 * 
	 * @param ids
	 * @param userContext
	 * @return
	 */
	@Auditable(false)
	List<T> findByIds(long[] ids);

	/**
	 * 
	 * @param userContext
	 * @return
	 */
	@Auditable(false)
	@Remoting(false)
	List<T> findAll();

	/**
	 * 
	 * @param ordering
	 * @param userContext
	 * @return
	 */
	@Auditable(false)
	List<T> findAll(Ordering ordering);

	@Remoting(false)
	String getNamespace();

	long sequence();

	@Remoting(false)
	void save(List<T> models, BatchAccessCallback<T> batchAccessCallback);

	@Remoting(false)
	List<T> saveList(List<T> models);

	/**
	 * 
	 * @param model
	 * @param userContext
	 * @return
	 */
	T save(T model);

	/**
	 * 
	 * @param model
	 * @param userContext
	 * @return
	 */
	T create(T model);

	/**
	 * Used createList instead.
	 * 
	 * @param models
	 * @param userContext
	 * @return
	 */
	@Remoting(false)
	int create(List<T> models);

	/**
	 * retrieve/read/find duplicate
	 */
	// List<T> findByIds(long[] ids);
	@Remoting(false)
	T findOne(final String statement, CriteriaParameter parameter);

	@Remoting(false)
	T findOne(final String statement, Map<String, Object> parameter);

	@Remoting(false)
	T findOne(CriteriaParameter parameter);

	T findOne(Map<String, Object> parameter);

	@Remoting(false)
	List<T> find(final String statement, Map<String, Object> parameter, Ordering ordering);

	@Remoting(false)
	List<T> find(final String statement, CriteriaParameter parameter, Ordering ordering);

	@Remoting(false)
	List<T> find(Map<String, Object> parameter, Ordering ordering);

	@Remoting(false)
	List<T> find(CriteriaParameter parameter, Ordering ordering);

	@Remoting(false)
	List<T> find(final String statement, Map<String, Object> parameter);

	@Remoting(false)
	List<T> find(final String statement, CriteriaParameter parameter);

	@Remoting(false)
	List<T> find(Map<String, Object> parameter);

	@Remoting(false)
	List<T> find(CriteriaParameter parameter);

	// @Remoting(false)
	List<T> find(String statement, Map<String, Object> parameters, int skipResult, int maxResult, Ordering ordering);

	@Remoting(false)
	List<T> find(String statement, CriteriaParameter parameter, int skipResult, int maxResult, Ordering ordering);

	@Remoting(false)
	List<T> find(Map<String, Object> parameters, int skipResult, int maxResult, Ordering ordering);

	@Remoting(false)
	List<T> find(CriteriaParameter parameter, int skipResult, int maxResult, Ordering ordering);

	@Remoting(false)
	List<T> find(Map<String, Object> parameters, int skipResult, int maxResult);

	@Remoting(false)
	List<T> find(CriteriaParameter parameter, int skipResult, int maxResult);

	// @Remoting(false)
	Pagination<T> findPagination(final String statement, Map<String, Object> parameter, Ordering ordering, final Pagination<T> pagination);

	@Remoting(false)
	Pagination<T> findPagination(final String statement, CriteriaParameter parameter, Ordering ordering, final Pagination<T> pagination);

	@Remoting(false)
	Pagination<T> findPagination(Map<String, Object> parameter, Ordering ordering, final Pagination<T> pagination);

	@Remoting(false)
	Pagination<T> findPagination(Map<String, Object> parameter, Ordering ordering, final Pagination<T> pagination, int skipResult, int maxResult);

	@Remoting(false)
	Pagination<T> findPagination(CriteriaParameter parameter, Ordering ordering, final Pagination<T> pagination);

	@Remoting(false)
	Pagination<T> findPagination(CriteriaParameter parameter, Ordering ordering, final Pagination<T> pagination, int skipResult, int maxResult);

	@Remoting(false)
	Pagination<T> findPagination(Map<String, Object> parameter, final Pagination<T> pagination);

	@Remoting(false)
	Pagination<T> findPagination(CriteriaParameter parameter, final Pagination<T> pagination);

	@Remoting(false)
	Pagination<T> findPagination(Ordering ordering, Pagination<T> pagination);

	@Remoting(false)
	Pagination<T> findPagination(Pagination<T> pagination);

	@Remoting(false)
	Pagination<T> findPagination();

	/** count */
	int count(final String statement, Map<String, Object> parameter);

	@Remoting(false)
	int count(final String statement, CriteriaParameter parameter);

	/** update */

	/**
	 * 
	 * @param model
	 * @param userContext
	 * @return
	 */
	T update(T model);

	/** remove */

	/**
	 * 
	 * @param model
	 * @param userContext
	 * @return
	 */
	T remove(T model);

	@Remoting(false)
	int remove(String statement, Map<String, Object> parameter);

	@Remoting(false)
	int remove(String statement, CriteriaParameter parameter);

	List<T> removeList(List<T> models);

}
